package com.org.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.org.model.Conferenceroom;
import com.org.mapper.ConferenceroomMapper;
import com.org.service.IConferenceroomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author test
 * @since 2021-06-05
 */
@Service
public class ConferenceroomServiceImpl extends ServiceImpl<ConferenceroomMapper, Conferenceroom> implements IConferenceroomService {
    @Autowired
    private ConferenceroomMapper mapper;

    @Override
    public List<Map<String,Object>> selectAllRoom() {
        QueryWrapper<Conferenceroom> queryWrapper = new QueryWrapper<>();
        queryWrapper.isNotNull("c_id");
        List<Map<String,Object>> maps = mapper.selectMaps(queryWrapper);
        return maps;
    }

    @Override
    public IPage<Conferenceroom> selectIsUsePage(Page<Conferenceroom> page) {
        return mapper.selectIsUsePage(page);
    }

    @Override
    public String getRoomName(Integer id) {
        Conferenceroom room = mapper.selectById(id);
        String name = room.getName();
        return name;
    }

    @Override
    public Conferenceroom getByCid(Integer cid) {
        return mapper.getByCid(cid);
    }

    @Override
    public Conferenceroom getIdByName(String name) {
        return mapper.getIdByName(name);
    }

    @Override
    public List<Conferenceroom> getRoomByCount(Integer count) {
        return mapper.getRoomByCount(count);
    }
}
